package com.examplemartin.jpademo.pojo.po.good;

import com.examplemartin.jpademo.annotation.EntityCheck;
import com.examplemartin.jpademo.pojo.admin.BaseEntity;
import com.examplemartin.jpademo.pojo.po.purchase.PurDetailPO;
import com.examplemartin.jpademo.pojo.po.repository.purchase.PurInDetailPO;
import com.examplemartin.jpademo.pojo.po.repository.sell.SellOutDetailPO;
import com.examplemartin.jpademo.pojo.po.sell.SellDetailPO;
import com.examplemartin.jpademo.pojo.po.sell.ShortDetailPO;
import com.examplemartin.jpademo.pojo.po.stock.RepoInfoPO;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 商品实体
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Entity(name = "t_good")
public class GoodPO extends BaseEntity implements Serializable {
    public static Integer GOOD_STATUS_LOCKED = -1;
    public static Integer GOOD_STATUS_NORMAL = 1;

    @EntityCheck(required = true, errRequired = "必须输入商品名")
    private String name;
    private Integer status = GOOD_STATUS_NORMAL;
    @EntityCheck(required = true, errRequired = "必须输入商品规格")
    private String spec;// 商品规格
    private String pk = "保留"; // 包装
    private String unit; // 计量单位

    private String comment;

    // 供应商 list


    /**
     * 销售部分
     */
    // 销售订单明细 list
    @OneToMany(mappedBy = "goodPO")
    @JsonIgnore
    private List<SellDetailPO> sellDetailPOList;



    /**
     * 采购部分
     */
    // 采购订单明细 list
    @OneToMany(mappedBy = "goodPO")
    @JsonIgnore

    private List<PurDetailPO> purDetailPOList;



    /**
     * 销售库存部分
     */
    // 销售订单出库单明细 list
    @OneToMany(mappedBy = "goodPO")
    @JsonIgnore
    private List<SellOutDetailPO> sellOutDetailPOList;



    // 销售缺货单明细 List
    @OneToMany(mappedBy = "goodPO")
    @JsonIgnore
    private List<ShortDetailPO> shortDetailPOList;


    /**
     * 采购库存部分
     */
    // 采购订单入库单明细 list
    @OneToMany(mappedBy = "goodPO")
    @JsonIgnore
    private List<PurInDetailPO> purInDetailPO;

    // 库存部分
    // 库存信息 list
    @OneToMany(mappedBy = "goodPO")
    @JsonIgnore
    private List<RepoInfoPO> repoInfoPOList;
    // 补货单明细 list
//    @OneToMany(mappedBy = "goodPO")
//    @JsonIgnore
//    private List<ReplentDetailPO> replentDetailPOList;

    @Override
    public String toString() {
        return "GoodPO{" +
                "name='" + name + '\'' +
                ", status=" + status +
                ", spec='" + spec + '\'' +
                ", pk='" + pk + '\'' +
                ", unit='" + unit + '\'' +
                ", comment='" + comment + '\'' +
                '}';
    }


}
